package me.zhulu.outOfMemory;

/**
 * Created with IntelliJ IDEA.
 * User: herosea
 * Date: 14-5-8
 * Time: 上午10:05
 * To change this template use File | Settings | File Templates.
 */
public class JavaVMStackOOM {

    private void dontStop() {
        while (true) {
        }
    }

    public void stackLeakByThread() {
        while (true) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    dontStop();
                    Object o;
                }
            });
            thread.start();
        }
    }

    public static void main(String[] args) {
        JavaVMStackOOM javaVMStackOOM = new JavaVMStackOOM();
        javaVMStackOOM.stackLeakByThread();
    }
}
